﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>驰骋流程&表单设计器 </title>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../../Comm/JS/validation.js"></script>
    <base target="_self" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../../Style/skin/css/login.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <style>
        #DDL_System::-ms-expand {
            display: none;
        }

        #DDL_System {
            padding: 5px 10px;
            border: 1px solid #dcd8d8;
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none; /*去掉下拉箭头*/
        }
    </style>
    <script type="text/javascript">

        document.onkeydown = function (e) {
            e = e || window.event;
            if (e.keyCode == 13) {
                Login();
                return false;
            }
        }

        //初始化页面函数.....
        $(function () {

          
            if (! +[1,]) {
                //  alert("这是ie浏览器，您只能使用sliverlight版本浏览器。");
                // window.location.href = '../XAP/Designer.htm';
                // return;
            }

            $("#Msg").html("<img src='../../Img/loading.gif' /><font color=blue>ccbpm 正在为登录/自动升级做准备.</font>");

            document.getElementById("Btn_Login").disabled = 'disabled';
            // document.getElementById("Btn_LoginSimple").disabled = 'disabled';

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_CCBPMDesigner");
            var data = handler.DoMethodReturnJSON("Login_InitInfo");
            document.title = data.SysName;

            //执行更新检查..
            var doType = GetQueryString("DoType");
            if (doType == null)
                doType = "Login_Init";

            handler.AddUrlData();
            //handler.AddFormData();
            //handler.AddPara("ss",val);
            data = handler.DoMethodReturnString(doType);

            if (data.indexOf('err@') == 0) {

                $("#Msg").html("<font color=red>" + data + ". 也许是: java/.net/phtyon 运行环境没有准备好导致的. 请确认运行环境</font>");
                return;
            }

            if (data.indexOf('url@') == 0) {
                var url = data.replace('url@', '');
                window.location.href = url;
                return;
            }

            document.getElementById("Btn_Login").disabled = false;
            // document.getElementById("Btn_LoginSimple").disabled = false;

            $("body").keydown(function () {
                if (event.keyCode == 13) {
                    event.cancelBubble = true;
                    event.returnValue = false;
                    Login();
                }
            });

            $("#Msg").html("<font color=green>" + data + "</font>");

        });

        //执行后台登录.
        function Login() {

            $("#Msg").html("<font> ccbpm 正在登录流程&表单引擎设计器,请稍候... </font>");

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_CCBPMDesigner");

            var userNo = $("#TB_No").val();
            var pass = $("#TB_PW").val();

            if (userNo == "" || pass == "") {
                $("#Msg").html("<font>请输入用户名，密码.</font>");
                return;
            }
            //判断验证码是否正确
            var node = $("#validate");
            if (node.is(':visible')) {
                if (!validateCode()) {
                    return;
                }
            }

            handler.AddPara("TB_No", userNo);
            handler.AddPara("TB_PW", pass);

            var data = handler.DoMethodReturnString("Login_Submit");

            if (data.indexOf('err@') == 0) {
                $("#Msg").html("<font color=red>" + data + "</font>");
                $("#validate").show();
                createCode();
                return;
            }

            if (data.indexOf("Install") != -1) {
                var data = data.replace('url@', '');
                window.location.href = data;
                return;
            }

            var systemp = $("#DDL_System").val();
            if (data.indexOf('url@') == 0) {
                var data = data.replace('url@', '');
                window.location.href = data.replace("Default.htm", systemp + ".htm");
                return;
            }

            //跳转到选择组织的页面
            if (data.length > 1) {
                window.location.href = "SelectOneOrg.htm";
                //WinOpen("SelectOneOrg.htm", "self");
                return;
            }
            alert(data);
        }

        // 选择系统后登录.
        function SelectChange() {
            var val = $("#DDL_System").val();
        }
        //设置cookies值
        function setCookie(cname, cvalue, exdays) {
            var d = new Date();
            d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
            var expires = "expires=" + d.toGMTString();
            document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
        }
        //获取cookies值
        function getCookie(cname) {
            var name = cname + "=";
            var decodedCookie = decodeURIComponent(document.cookie);
            var ca = decodedCookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') {
                    c = c.substring(1);
                }
                if (c.indexOf(name) == 0) {
                    return c.substring(name.length, c.length);
                }
            }
            return "";
        }
        //检查cookies值
        function checkCookie() {
            var user = getCookie("username");
            if (user != "") {
                $(" select option[value='" + user + "']").attr("selected", "selected");
            } else {

                if (user != "" && user != null) {
                    setCookie("username", user, 30);
                }
            }
        }
    </script>

    <style>
        .imgsty {
            display: inline-block;
            height: auto;
            max-width: 100%;
        }
    </style>
</head>

<body class="login-bg" onload="checkCookie()">

    <form id="cc">
        <div class="login-box_admin">
            <!--<h1 class="logo-name">驰骋流程&表单设计器</h1>-->
            <div style="margin-bottom: 10px">
                <img class="imgsty" src="../../../DataUser/ICON/IconSmall.png" alt="" />
            </div>
            <div class="login-form">
                <div class="form-group">
                    <b>您要登录的系统:</b>
                    <select class="form-control" style=" width:auto;display:inline" id="DDL_System" onchange="SelectChange()">
                        <option value="Default" onclick="setCookie('username', $(this).val(), 30)"> 驰骋BPM专业版 </option>
                        <option value="DefaultSimple" onclick="setCookie('username', $(this).val(), 30)">驰骋BPM极简版(beta)</option>
                        <option value="DefaultFrm" onclick="setCookie('username', $(this).val(), 30)"> 驰骋表单引擎(beta)</option>
                        <option value="DefaultGPM" onclick="setCookie('username', $(this).val(), 30)"> 驰骋权限管理(beta)</option>
                    </select>
                </div>

                <div class="form-group">
                    <input type="text" id="TB_No" name="TB_No" value="admin" placeholder="请输入账号" lay-verify="required" class="form-control" />
                </div>
                <div class="form-group">
                    <input type="password" id="TB_PW" name="TB_PW" placeholder="请输入密码" lay-verify="required" class="form-control" />
                </div>
                <div id="validate" class="form-group" style="display: none">

                    <input type="text" class="form-control" placeholder="验证码" id="inputCode" style="width:50%;display: inline" />
                    <canvas id="canvas" width="78" height="24"></canvas>
                    <a href="javascript:void(0)" style="margin-left: 10px" onclick="createCode()">看不清</a>
                </div>
                <input type="button" class="btn btn-primary btn-block" value="登录" id="Btn_Login" onclick="Login();" />
                <!--//  <input type="button" class="btn btn-primary btn-block" value="登录简洁版(开发中)" id="Btn_LoginSimple" onclick="LoginSimple();" />
                // <input type="button" class="btn btn-primary btn-block" value="登录表单引擎(开发中)" id="Btn_LoginFrm" onclick="LoginFrm();" />-->

                <div class="row login-nav">
                    <div class="col-xs-6">默认密码：123</div>
                    <div class="col-xs-6 ">

                        <a href="../../AppClassic/Login.htm" class="pull-right">前台登录</a>

                        <a href="http://ccbpm.mydoc.io" target=_blank class="pull-right">帮助文档&nbsp;&nbsp;</a>

                    </div>
                    <br />
                    <div id="Msg" style=" float:right;margin-right:14px">
                    </div>
                </div>
            </div>
        </div>
    </form>


</body>
</html>
